//
//  MyCardVC.m
//  QoilPublic
//
//  Created by SunChao on 17/9/6.
//  Copyright © 2017年 杨凯. All rights reserved.
//

#import "MyCardVC.h"
#import "ShowCardCell.h"
#import "AddMyCardCell.h"
@interface MyCardVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UITableView *tbView;
@property (nonatomic,strong)NSMutableArray *dataSource;
@end

@implementation MyCardVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的银行卡";
    NSArray *array = @[@"交通银行",@"招商银行"];
    self.dataSource = array.mutableCopy;
    [self.view addSubview:self.tbView];
    [self.tbView registerNib:[UINib nibWithNibName:@"ShowCardCell" bundle:nil] forCellReuseIdentifier:@"ShowCardCell"];
     [self.tbView registerNib:[UINib nibWithNibName:@"AddMyCardCell" bundle:nil] forCellReuseIdentifier:@"AddMyCardCell"];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == self.dataSource.count) {
        return 60;
    }
    return 80;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dataSource.count+1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == self.dataSource.count) {
        AddMyCardCell * cell= [tableView dequeueReusableCellWithIdentifier:@"AddMyCardCell" forIndexPath:indexPath];
        return cell;
    }
    ShowCardCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ShowCardCell"];
    UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(15, 5, kScreenWidth-30, 70)];
    UIImageView *imgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"mySelfHeadImage1@2x"]];
    imgView.frame = bgView.frame;
    [imgView setContentMode:UIViewContentModeScaleAspectFill];
    imgView.clipsToBounds = YES;
    imgView.layer.cornerRadius= 10;
    imgView.layer.masksToBounds=YES;
    [bgView addSubview:imgView];
    [cell setBackgroundView:bgView];
    return cell;
    
}
-(NSMutableArray *)dataSource{
    if (!_dataSource ) {
        _dataSource = [NSMutableArray array];
    }
    return _dataSource;
}
- (UITableView*)tbView {
    if (!_tbView) {
        _tbView = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
        _tbView.dataSource = self;
        _tbView.delegate = self;
        _tbView.backgroundColor = [UIColor whiteColor];
        _tbView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
       _tbView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tbView;
}

@end
